'''
@Project ：python-study
@File    ：9.6饼图：电影语种统计.py
@IDE     ：PyCharm
@Author  ：SUNLIN
@Date    ：2025/3/15 15:09:03
'''
import C8处理与分析.pandas_def as pdef
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']  # 使用黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

# 获取统计数据
file_path = 'D:\develop\projects\Python Project\python-study\doc\datasource\C8-8.5-数据采集-clean.xlsx'
usecols = ['movie_name', 'country', 'language', 'release_date', 'average_score', ]
language_tj = pdef.language_tj(file_path, usecols)
language_tj = language_tj.sort_values('tj', ascending=False)

print(language_tj.index)

language_tj = language_tj[0:6]
labels = language_tj.index
sizes = language_tj['tj'].tolist()

plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)
plt.title(u'电影语种统计')
plt.legend(title="电影", loc='center left', bbox_to_anchor=(1, 0, 0.5, 1))
plt.show()
